import { useSelector, useDispatch } from "react-redux";

import { increment, decrement } from "./appSlice";

export default function App() {
  // 读取数据方法
  const count = useSelector((state) => state.app.count);

  // 更新数据方法
  const dispatch = useDispatch();

  const handleIncrement = () => {
    dispatch(increment(1));
  };

  const handleDecrement = () => {
    dispatch(decrement(1));
  };

  return (
    <div>
      <h1>点击次数：{count}</h1>
      <button onClick={handleIncrement}>+</button>
      <button onClick={handleDecrement}>-</button>
    </div>
  );
}
